package movie.test.log;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import movie.test.as.log.service.LogService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;

@RestController
@RequestMapping("/log")
public class LogController {

	private static Logger logger = LoggerFactory.getLogger(LogController.class);

	@Autowired
    private LogService logServiceImpl;

	@ResponseBody
	@RequestMapping("/insertLog")
   public Object insertLog(@RequestBody JSONObject objs,HttpServletRequest servlet){
		logServiceImpl.insertLog(objs);
	   
	   return null;
   }
	
	@ResponseBody
	@RequestMapping(value={"/findAllLogList"},method={RequestMethod.GET,RequestMethod.POST})
	public Object findAllLogList(@RequestBody JSONObject objs,HttpServletRequest request) {
		try {
			logger.debug("查询所有日志开始");
			 PageInfo<Map<String,Object>>  listUsers = logServiceImpl.findAllLogList(objs);
			logger.info("查询所有日志结束");
			LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
			map.put("result", listUsers);
			return map;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
